package com.zhu.transaction.pojo;

import com.sun.org.apache.xpath.internal.operations.Or;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @author Zhu
 * @createtime 2021/2/21-9:04
 */
@Data
@ToString
@Accessors(chain = true)
public class OrderItem {
    String orderId;
    List<Product> productList;
    List<Order> OrderList;
    Float totalPrice;
    String productNames;
    int orderState;
    String purchaseTime;
    String userName;
    String phone;
    String address;

    public OrderItem setTotalPrice(Float totalPrice) {
        this.totalPrice = new BigDecimal(totalPrice).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
        return this;
    }

    public OrderItem setPurchaseTime(Date purchaseTime) {
        this.purchaseTime = new SimpleDateFormat("yy-MM-dd HH:mm").format(purchaseTime);
        return this;
    }
}
